package com.eliansun.util;

import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;

/**
 * 图表工具类
 * @author ljh
 * @version 1.0.0
 * @date 2018/7/12
 */
public class ChartUtil {

    public static final String LINE = "line";
    public static final String MAX = "max";
    public static final String MAXNAME = "最大值";
    public static final String MIN = "min";
    public static final String MINNAME = "最小值";
    public static final String STEPMIDDLE = "Step Middle";
    public static final String MIDDLE = "middle";

    /**
     * 获取series中每个值中的itemStyle
     * @return
     */
    public static Map<String, Object> getItemStyle() {
        Map<String, Object> itemStyle = new HashMap<>(1);
        Map<String, Object> itemStyleLabel = new HashMap<>(1);
        Map<String, Object> itemStyleLabelShow = new HashMap<>(1);
        itemStyleLabelShow.put("show", true);
        itemStyleLabel.put("label", itemStyleLabelShow);
        itemStyle.put("normal", itemStyleLabel);
        return itemStyle;
    }

    /**
     * 获取series中markPoint
     * @return
     */
    public static Map<String,Object> getMarkPoint(){
        Map<String,Object> markPoint = new HashMap<>(1);
        Map<String,Object> markPointDataMax = new HashMap<>(2);
        markPointDataMax.put("type",MAX);
        markPointDataMax.put("name",MAXNAME);
        Map<String,Object> markPointDataMin = new HashMap<>(2);
        markPointDataMin.put("type",MIN);
        markPointDataMin.put("name",MINNAME);
        markPoint.put("data",Arrays.asList(markPointDataMax,markPointDataMin));
        return markPoint;
    }


    /**
     * 获取series中getMarkLine
     * @return
     */
    public static Map<String,Object> getMarkLine(){
        Map<String,Object> markLine = new HashMap<>(2);
        Map<String,Object> markLineData = new HashMap<>(1);
        markLineData.put("type",MAX);
        markLineData.put("name",MAXNAME);
        markLine.put("data",Arrays.asList(markLineData));
        return markLine;
    }
}
